<?php 
define('_VIEW_MODEL_','admin');
session_start();
$statu = $_SESSION['statu'];
$linkinfo = "";
require_once("../init.php");
if(!$statu){
	echo "<script>window.parent.location.href='./index.php'</script>";
}
if(isset($act)&&$act=="add"){
	//echo "insert into {$telper}friendlink set `title` = '$linkname',`link` = '$linkaddres',`rank` = '$linkrank',`state` = '$linksta'";
	//exit;
	$db->Execute("insert into {$telper}friendlink set `title` = '$linkname',`link` = '$linkaddres',`rank` = '$linkrank',`state` = '$linksta'");
	header("Location:friends.php"); 
	exit;
}
if(isset($act)&&$act=="editlink"){
	$db->Execute("update {$telper}friendlink set `title` = '$linkname',`link` = '$linkaddres',`rank` = '$linkrank',`state` = '$linksta' where `id` ='$linkid'");
	header("Location:friends.php");	
	exit;
}
if(isset($act)&&$act=="edit"){
$id = intval($id);
	$linkinfo = $db->GetRow("select * from {$telper}friendlink where `id` = '$id'");
	if(empty($linkinfo)){
		echo "<script>window.parent.location.href='./index.php'</script>";
		exit;	
	}	
	$adminfriendname = $addminfriededit;
	$act = "editlink";
	$linkid = $id;
}else{
	$adminfriendname = $addminfriedadd;
	$act = "add";
	$linkid = "";
}

$smartyObj->assign('title',$admintitle);
$smartyObj->assign('linkinfo',$linkinfo);
$smartyObj->assign('adminfirendname',$adminfriendname);
$smartyObj->assign('act',$act);
$smartyObj->assign('linkid',$linkid);
$smartyObj->display("friendadd.tpl");
?>